function [ encodedSignal ] = encode( y, Fs )
%ENCODE Summary of this function goes here
%   Detailed explanation goes here

    %[y, Fs, ~, ~] = wavread(data);
    %[y, Fs, nbits, readinfo] = wavread('soundfile-wav/left_0.wav');
    
    fs = Fs / 100;
    
    %calculate the frame overlap
    frameOverlap = round(1/4 * fs);
    %y = y ./ max(abs(y));
    
    %Split the signal into frames
    frames = buffer(y, fs, frameOverlap);
    
    %create hamming matrix based on the size of the frames
    s = size(frames);
    ham = hamming(s(1));
    
    %not quite sure about this
    NFFT = 2^nextpow2(fs);
    
    numFeatures = 4;
    
    encodedSignal = zeros(numFeatures, s(2));
    
    for i = 1:s(2)
        %calculate the hamming frames
        hamFrame = frames(:,i) .* ham;
        
        %translate from time space to frequency space
        fourier = fft(hamFrame, NFFT) / fs;
        
        %http://www.mathworks.se/help/techdoc/ref/fft.html
        f = Fs/2*linspace(0,1,NFFT/2+1);
        %find the peaks in the signal
        [~, LOCS] = findpeaks(abs(fourier(1:NFFT/2+1)), 'SORTSTR', 'descend');
        encodedSignal(:,i) = f(LOCS(1:numFeatures));
    end
end

